package com.sayyi.validate.domain;

import lombok.Data;

import javax.validation.constraints.*;

/**
 * @author xuchuang
 * date 2021/12/2 10:30 上午
 */
@Data
public class Order {

    @NotNull(message = "车架号不能为空")
    @Size(min = 17, max = 17, message = "车架号应为{min}位")
    private String vin;

    @Size(max = 20, message = "里程保证金应小于{max}位")
    private String guaranteedPrice;

    @Digits(integer = 10, fraction = 2, message = "采购含税单价最多两位小数")
    @DecimalMin(value = "0", message = "采购含税单价最小为{value}")
    @DecimalMax(value = "500000", message = "采购含税单价最大为{value}")
    private String purchasePrice;

    @Digits(integer = 10, fraction = 2, message = "首付款最多两位小数")
    @DecimalMin(value = "0", message = "首付款最小为{value}")
    @DecimalMax(value = "99990000", message = "首付款最大为{value}")
    private String downPayment;

    @AssertTrue(message = "采购含税单价不为空时，首付款不能为空")
    public boolean isOK() {
        return purchasePrice == null || downPayment != null;
    }
}
